package com.dennisstepp.depressionglass.activities;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

import com.dennisstepp.R;
import com.dennisstepp.database.DepressionGlassDbAdapter;

public class VitrockActivity extends ListActivity {
	private static DepressionGlassDbAdapter db;
	private static Cursor c;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		String[] from = new String[] { DepressionGlassDbAdapter.KEY_PIECE,
				DepressionGlassDbAdapter.KEY_VALUE,
				DepressionGlassDbAdapter.KEY_QUANTITY };

		int[] to = new int[] { R.id.pieceText, R.id.valueText,
				R.id.quantityText };

		db = new DepressionGlassDbAdapter(this);
		db.open();

		c = db.fetchAllVitrock();

		SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
				R.layout.depressionglasslayout, c, from, to);
		setListAdapter(adapter);
	}

	@Override
	protected void onPause() {
		c.close();
		db.close();
		super.onPause();
	}

}
